#!/usr/bin/env python
# -*- coding: utf8 -*-
# title       :
# description :
# author      :'ShenMeng'

import yaml
import os

def yaml_include(loader, node):
    file_path = os.path.dirname(loader.name)
    value = node.value
    if not os.path.isfile(value):
        value = os.path.join(file_path, value)
        if not os.path.isfile(value):
            return
    with file(value) as inputfile:
        return yaml.load(inputfile)

def parse_yaml_file(file):
    yaml.add_constructor("!include", yaml_include)
    if os.path.isfile(file):
        with open(file) as f:
            data = yaml.load(f)
        return data
    return False
